*************************** * MSG Source Code * * by Sandy Mossberg * * Copyright (C) 1989 * * by MicroSPARC, Inc. * * Concord, MA 01742 * * * * APW Environment * * Run under APW Shell * *************************** SETCOM 36 ;comment line at column 38 MCOPY MSG.MAC ;macro definitions file KEEP MSG ;load file MATPtr GEQU $00 ;ptr to Message Address Table (MAT) MTTPtr GEQU $04 ;ptr to char in Message Text Table (MTT) MTTPtrSave GEQU $08 ;ptr to start of msg in MTT MsgCount GEQU $0C ;entry offset in MAT MSGPOINTER GEQU $E100C0 ;vector of Message Address Table Msg_Code START ***| MAIN CODE |************************************************* ;................................................................ ; ; Equate data bank with program bank: ; PHK PLB ;................................................................ ; ; Save current I/O configuration on stack: ; PHA ;space for input device code PushLong #0 ;space for input slot/vector _GetInputDevice PHA ;space for input AND mask PHA ;space for input OR mask _GetInGlobals PHA ;space for output device code PushLong #0 ;space for output slot/vector _GetOutputDevice PHA ;space for output AND mask PHA ;space for output OR mask _GetOutGlobals ; Set slot 3 BASIC-type text I/O: PushWord #0 ;BASIC device type PushLong #3 ;Input from slot 3 _SetInputDevice PushWord #$FF ;AND mask (no change) PushWord #$80 ;OR mask (set hi bit) _SetInGlobals PushWord #0 ;BASIC device type PushLong #3 ;Output to slot 3 _SetOutputDevice PushWord #$FF ;AND mask (no change) PushWord #$80 ;OR mask (set hi bit) _SetOutGlobals PushWord #0 ;init input device _InitTextDev PushWord #1 ;init output device _InitTextDev ;................................................................ ; ; Point at Message Address Table: ; LDA MSGPOINTER ;set lo order bytes STA MATPtr ; of MAT LDA MSGPOINTER+2 ;set hi order STA MATPtr+2 ; of MAT STA MTTPtr+2 ; and MTT STA MTTPtrSave+2 STZ MsgCount ;zero entry offset for MAT ;................................................................ ; ; Point at Message Text Table: ; SetMTTPtr LDA MsgCount CMP #$00FE ;254 messages in MTT BCS Exit ;all messages printed so exit ASL A ;double index to 2-byte entries TAY ; in MAT and transfer to Y-reg LDA [MATPtr],Y ;get address of 1st message in MTT STA MTTPtr ; and save in both STA MTTPtrSave ; ptrs to MTT ;................................................................ ; ; Print message on screen (lifted from Visit Monitor): ; ; Print individual characters: JSR PrintCount ;print message number SEP #$70 ;set m,x,v flags LONGA OFF ; 8-bit accum and memory LONGI OFF ; 8-bit index LDA [MTTPtr] ;get 1st char in message BEQ BumpPtr ;zero keeps v-set for MouseText CMP #$20 BCC Repeat ;repeat signal encountered CLV ;v-clear signals no MouseText NextChar LDA [MTTPtr] ;get next char in message BEQ EndMsg ;end of message CMP #$20 BCC Repeat ;repeat signal encountered BVS CharOut ;allow MouseText BMI CharOutEnd ;print last char in message ORA #$80 ;disallow MouseText CharOut JSR PrintChar ;output char BumpPtr INC MTTPtr ;point to next char BNE NextChar INC MTTPtr+1 BRA NextChar ; End message: CharOutEnd JSR PrintChar ;output final char in message EndMsg JSR PrintCode ;show raw message code BCS Exit ;abort signal given INC MsgCount ;point to next MAT entry BRA SetMTTPtr ;back for another message ; Print repeat characters: Repeat TAY ;Y-reg counts repetitions of next char INC MTTPtr ;point to next char BNE RepeatChar INC MTTPtr+1 RepeatChar LDA [MTTPtr] ;get char to repeat PHY ;save counter BVS RepeatOut ;allow MouseText ORA #$80 ;disallow MouseText RepeatOut JSR PrintChar ;output repeat char PLY ;retrieve counter DEY ;reduce count BNE RepeatChar ;keep keep repeating BRA BumpPtr ;exit repeat loop ;................................................................ ; ; Restore entry I/O configuration and exit program: ; Exit LONG ;clear m,x flags _SetOutGlobals ;input parameters on stack _SetOutputDevice _SetInGlobals _SetInputDevice PushWord #0 ;init input device _InitTextDev PushWord #1 ;init output device _InitTextDev RTL ***| SUBROUTINES |*********************************************** ;................................................................ ; ; Print character: ; PrintChar PHP ;save entry status PHY ;save Y-counter LONG ;clear m,x flags AND #$00FF ;zero hi byte CMP #$0040 BCC PCh1 ;not a MouseText char CMP #$0060 BCS PCh1 ;not a MouseText char PHA ;codes $40-$5F signify WRITESTR MTextOn ; MouseText chars so PLA ; turn on MouseText mode PCh1 WRITECH ;output char WRITESTR MTextOff ;disable MouseText mode SHORT ;set m,x flags PLY ;restore Y-counter PLP ;restore status RTS ;................................................................ ; ; Print raw message code: ; ; Print hex characters: PrintCode LONG ;clear m,x flags WRITECH #$9D ;clear to end of line WRITELN ;print CR PCo1 LDA [MTTPtrSave] ;get message char AND #$00FF ;zero hi byte PHA ;hex number PushLong #HexNum ;ptr to ASCII result PushWord #2 ;length of ASCII string _Int2Hex ;get ASCII of hex number PushLong #HexNum ;ptr to ASCII number _WriteCString ;print error code INC MTTPtrSave ;bump ptr to message char LDA MTTPtrSave CMP MTTPtr ;have we reached end of message? BCC PCo1 ;no, back for BEQ PCo1 ; another char ; Check for ESC abortion: WRITELN ;print CR WRITELN ;print CR PHA ;space for result PushWord #0 ;no echo _ReadChar ;get keypress PLA ;retrieve char AND #$00FF ;zero hi byte CMP #$009B ;ESC char BEQ PCo2 ;CS = abort program CLC ;CC = continue to next message PCo2 RTS ;................................................................ ; ; Print message number: ; PrintCount WRITECH #$8F ;set inverse text mode WRITESTR #' Message Number:' LDA MsgCount ;get MAT offset INC A ;bump to get message number PHA ;line number PushLong #DecMsgNum ;ptr to ASCII result PushWord #3 ;length of ASCII string PushWord #0 ;unsigned number _Int2Dec ;get ASCII of decimal number PushLong #DecMsgNum ;ptr to ASCII number _WriteCString ;print line number (right justified) WRITECH #$8E ;set normal text mode WRITELN #' ' ;kill inverse mode WRITELN ;print CR RTS ***| STORAGE |*************************************************** HexNum DS 2 ;ASCII C-string of hex number DC H'A0 00' ;1 space + zero terminator DecMsgNum DS 3 ;ASCII C-string of decimal number DC H'A0 00' ;1 space + zero terminator MTextOn DC H'02 8F 9B' ;length byte + enable MouseText MTextOff DC H'02 8E 98' ;length byte + disable MouseText END